<template>
	<view class="content">
		<musichead title="网易云音乐" :icon="false" ></musichead>
		<view class="container">
			<scroll-view scroll-y="true">
				<view class="index-search">
					<text class="iconfont icon-sousuo"></text>
					<input type="text" placeholder="搜索歌曲">
				</view>
				<view class="index-list">
					<view class="index-list-item" v-for="(item,index) in topList" :key="item.id" @tap="handleToList" :data-id="item.id">
						<view class="index-list-img">
							<image :src="item.coverImgUrl" mode=""></image>
							<text>{{item.updateFrequency}}</text>
						</view>
						<view class="index-list-text" >
							<view v-for="(musicitem, index) in item.tracks" :key="index">{{index+1}}.{{musicitem.first}} - {{musicitem.second}}</view>
						</view>
					</view>	
				</view>
			</scroll-view>
			
		</view>
	</view>
</template>

<script>  
	import '@/common/iconfont.css';
	import musichead from '../../components/musichead/musichead.vue'
	import {topList} from '../../common/api.js'
	export default {
		data() {
			return {
				topList: []
			}
		},
		onLoad() {
			topList().then((res)=>{
				if(res.length){
					console.log(res);
					this.topList = res;
				}
			});
		},
		components:{
			musichead
		},
		methods: {
			handleToList(event){
				uni.navigateTo({
					url: '../list/list?listId=' + event.currentTarget.dataset.id
				})
			},
		}
	}
</script>

<style scoped>
	.index{
		
	}
	.index-search{
		display: flex;
		align-items: center;
		height: 70rpx;
		margin: 70rpx 30rpx 30rpx 30rpx;
		background: #f7f7f7;
		border-radius: 50rpx;
	}
	.index-search text{
		font-size: 26rpx;
		margin-right: 26rpx;
		margin-left: 28rpx;
	}
	.index-search input{
		font-size: 28rpx;
		flex: 1;
	}
	
	.index-list{
		margin: 0 30rpx;
	}
	.index-list-item{
		display: flex;
		margin-bottom: 34rpx;
	}
	.index-list-img{
		position: relative;
		overflow: hidden;
		width: 212rpx;
		height: 212rpx;
		border-radius: 30rpx;
		margin-right: 22rpx;
	}
	.index-list-img image{
		width: 100%;
		height: 100%;
	}
	.index-list-img text{
		position: absolute;
		left: 12rpx;
		bottom: 16rpx;
		color: white;
		font-size: 20rpx;
	}
	.index-list-text{
		font-size: 24rpx;
		line-height: 66rpx;
	}
	
	
</style>
